import request from '@/utils/request'
// 定义接口常量
const API_ROLE = '/admin/system/sysRole'
// 角色管理接口  /admin/system/sysRole
export default {

  getRoleById(id) {
    return request({
      url: `${API_ROLE}/get/${id}`,
      method: 'post'
    })
  },
  //更新角色
  updateRole(role) {
    return request({
      url: `${API_ROLE}/update`,
      method: 'put',
      data: role
    })
  },

  // 添加角色
  saveRole(role) {
    return request({
      url: `${API_ROLE}/save`,
      method: 'post',
      data: role
    })
  },
  // 获取角色列表
  getPageList(page, limit, searchObj) {
    return request({
      url: `${API_ROLE}/findPageQueryRole/${page}/${limit}`,
      method: 'get',
      params: {
        searchObj
      }
    })
  },
  // 删除角色
  removeId(id) {
    return request({
      url: `${API_ROLE}/removeRole/${id}`,
      method: 'delete'
    })
  },
  // 批量删除角色
  batchremoveRoles(idList) {
    return request({
      url: `${API_ROLE}/batchRemove`,
      method: 'delete',
      data: idList
    })
  },
  //根据用户id查询用户已分配的角色
  getRolesByUserId(userId) {
    return request({
      url: `${API_ROLE}/toAssign/${userId}`,
      method: 'get'
    })
  },

//分配角色
  assignRoles(assginRoleVo) {
    return request({
      url: `${API_ROLE}/doAssign`,
      method: 'post',
      data: assginRoleVo
    })
  }

}

